<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>新建采购单表单</title>
</head>
<body>
<script>
    $(function () {
        $("#newPur-save").linkbutton({onClick:function () {
                $("#newPurchase-form").form({
                    method:'post',
                    onSubmit:function () {
                        return $(this).form("validate");
                    },
                    success:function (data) {
                        var data = eval("("+data+")");
                        if(data.success){
                            $("#newPurchase-form").form("clear");
                            $("#newPur").dialog("close");
                            $.messager.alert("success","添加采购成功!","info");
                            $("#purdg").datagrid({
                                url:'allPurPaged',
                                method:'post'
                            });
                            $("#purdg").datagrid("reload");
                        }else{
                            $.messager.alert("failed",data.message,"error");
                        }

                    }
                }).submit();
            }});
        $("#contact-search").combobox({
            onBeforeLoad: function(param){
                if(param == null || param.q == null || param.q.replace(/ /g, '') == ''){
                    var value = $(this).combobox('getValue');
                    if(value){// 修改的时候才会出现q为空而value不为空
                        param.id = value;
                        return true;
                    }
                    return false;
                }

            }});
        $("#client-search").combobox({
            onBeforeLoad: function(param){
                if(param == null || param.q == null || param.q.replace(/ /g, '') == ''){
                    var value = $(this).combobox('getValue');
                    if(value){// 修改的时候才会出现q为空而value不为空
                        param.id = value;
                        return true;
                    }
                    return false;
                }

            }});

        $("#newPur-close").linkbutton({onClick:function () {
                $("#newPur").dialog("close");
            }});
        $("#client-search").combobox({
            onChange:function (newValue,oldValue) {
                var queryParams = $("#contact-search").combobox('options').queryParams;
                queryParams.cid = $("#client-search").val();
            }
        });

    });
</script>
<div>
    <form id="newPurchase-form" action="newPurchase-form-sub" method="post">
        <div class="div-title-hut"> --------------------------------<span class="span-title">采购单信息</span>---------------------------</div>
        <div class="ddt">
            <input  name="purtheme" class="easyui-textbox" data-options="label:'采购主题',required:true,width:300"><div style="display: inline-block;margin-left: 5%;"></div>
            <input id="client-search" name="clientId" class="easyui-combobox" data-options="required:true,prompt:'模糊供应商名称',url:'getAllClientBymh',
        label:'供应商(客户)',valueField:'cid',textField:'cname',method:'post',editable:true,panelHeight:'auto',width:300,mode:'remote'" >
        </div>
        <div class="ddt">
            <input id="contact-search" name="contactId" class="easyui-combobox" data-options="required:false,prompt:'输入任意取值',url:'getAllContactBymh',
        label:'供应商联系人',valueField:'contactid',textField:'contactName',method:'post',editable:true,panelHeight:'auto',width:300,mode:'remote'" ><div style="display: inline-block;margin-left: 5%;"></div>
            <select id="user-search" class="easyui-combogrid" name="purUserId" style="width:300px;"
                    data-options="
            label:'经手人',
            panelWidth:330,
            prompt:'模糊经手人名称或昵称',
            required:true,
            panelHeight:'auto',
            idField:'handmanId',
            textField:'handman',
            mode:'remote',
            method:'post',
            url:'findUserBypiny',
            columns:[[
                {field:'handmanId',title:'用户编号',width:60},
                {field:'nickname',title:'用户昵称',width:100},
                {field:'handman',title:'用户实名',width:100}
            ]]
        "></select>
        </div>
        <div class="ddt">
            <input id="purdate" name="purdate" class="easyui-datebox" data-options="label:'采购日期',required:true,width:300"><div style="display: inline-block;margin-left: 5%;"></div>
            <input id="purexcepttime" name="purexcepttime" class="easyui-datebox" data-options="label:'预计到货日期',required:false,width:300">
        </div>
        <div class="ddt">
            <span>采购物品详情:</span><br>
            <input class="easyui-textbox" data-options="required:false,prompt:'保存后方可编辑明细',width:600,disabled:true">
        </div>
        <div class="ddt">
            <span>备注:</span><br>
            <input id="remarks" name="remarks" class="easyui-textbox" data-options="required:false,width:580,height:100,multiline:true">
        </div>
        <div class="btn" style="text-align:center;margin-top:50px;">
            <!--此按钮可根据自己业务自行修改或删除-->
            <a id="newPur-save" class="easyui-linkbutton " data-options="iconCls:'icon-ok2'">新建</a><div style="width: 20px;display: inline-block"></div>
            <a id="newPur-close" class="easyui-linkbutton" data-options="iconCls:'icon-cancel2'">取消</a>
        </div>
    </form>
</div>
</body>
</html>
